const { Model, DataTypes } = require("sequelize");

class AlarmRecord extends Model {
  static init(sequelize) {
    super.init(
      {
        id: {
          type: DataTypes.INTEGER,
          autoIncrement: true,
          primaryKey: true,
        },
        type: {
          type: DataTypes.STRING(20),
          allowNull: false,
        },
        current_value: {
          type: DataTypes.FLOAT,
          allowNull: false,
        },
        current_max: {
          type: DataTypes.FLOAT,
          allowNull: false,
        },
        remark: {
          type: DataTypes.TEXT,
          allowNull: true,
        },
        position: { // 预留字段
          type: DataTypes.STRING(40),
          allowNull: true,
        },
        createdAt: {
          type: DataTypes.DATE,
          allowNull: false,
        },
      },
      {
        sequelize,
        modelName: "AlarmRecord",
        tableName: "alarm_record",
        timestamps: false, // 禁用 Sequelize 默认的时间戳字段（createdAt 和 updatedAt）
      }
    );
  }

  static associate(models) {
    // 定义关联关系
  }
}

module.exports = AlarmRecord;
